using System.Data.Entity.ModelConfiguration;
using Turquoise.Entities.Data;

namespace Turquoise.DataAccess.EntityFramework.Mappings
{

    public class ContentCategoryMapping : EntityTypeConfiguration<ContentCategory>
    {
        public ContentCategoryMapping(string schema = "dbo")
        {
            ToTable(schema + ".ContentCategory");
            HasKey(x => x.Id);

            Property(x => x.Id).HasColumnName("Id").IsRequired().HasColumnType("int").HasDatabaseGeneratedOption(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity);
            Property(x => x.ContentTypeId).HasColumnName("ContentTypeId").IsRequired().HasColumnType("int");
            Property(x => x.ParentId).HasColumnName("ParentId").IsOptional().HasColumnType("int");
            Property(x => x.CreateDate).HasColumnName("CreateDate").IsRequired().HasColumnType("datetime");
            Property(x => x.CreatedBy).HasColumnName("CreatedBy").IsRequired().HasColumnType("int");
            Property(x => x.UpdateDate).HasColumnName("UpdateDate").IsRequired().HasColumnType("datetime");
            Property(x => x.UpdatedBy).HasColumnName("UpdatedBy").IsRequired().HasColumnType("int");

            HasRequired(a => a.ContentType).WithMany(b => b.ContentCategories).HasForeignKey(c => c.ContentTypeId);
            HasRequired(a => a.User_CreatedBy).WithMany(b => b.ContentCategories_CreatedBy).HasForeignKey(c => c.CreatedBy);
            HasRequired(a => a.User_UpdatedBy).WithMany(b => b.ContentCategories_UpdatedBy).HasForeignKey(c => c.UpdatedBy);
        }
    }

}

